from selenium import webdriver
from selenium.webdriver.common.by import By
import time
import unittest


class fanqiexiaoshuo(unittest.TestCase):

    def setUp(self) -> None:
        # 打开浏览器
        self.driver = webdriver.Chrome()
        self.driver.get('https://fanqienovel.com/')
        time.sleep(2)
        # 窗口最大化
        self.driver.maximize_window()
        self.driver.implicitly_wait(5)

    def tearDown(self) -> None:
        time.sleep(5)
        self.driver.quit()

    def test_fanqiexiaoshuo_01(self):
        # 点击登录
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/div[1]/div/div[2]/div[9]/div/div/div[1]').click()
        time.sleep(2)
        # 输入手机号
        self.driver.find_element(By.XPATH,
                            '/html/body/div[1]/div/div/div/div[3]/div[1]/div/div[2]/form/div[1]/div/input').send_keys(
            '15985645480')
        # driver.find_element(By.CLASS_NAME, 'username').send_keys('15985645480')
        # 强制等待 输入验证码
        time.sleep(30)
        # 点击用户协议
        self.driver.find_element(By.CLASS_NAME, 'arco-checkbox-mask').click()
        time.sleep(2)
        # 点击登录按钮
        self.driver.find_element(By.XPATH, '//*[@id="slogin-pc-login-form"]/div[2]/form/div[4]/button').click()
        time.sleep(2)
        # # 断言1：验证登录成功后断言：用户59965023
        dy1 = self.driver.find_element(By.CLASS_NAME, 'user-name').text
        self.assertEqual('用户59965023', dy1)



if __name__ == '__main__':
    unittest.main()
